package com.cms.web.servlet;

import com.cms.pojo.Admin;
import com.cms.pojo.Course;
import com.cms.service.CourseService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet("/allCourseServlet")
public class AllCourseServlet extends HttpServlet {
    private CourseService courseService = new CourseService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 调用CourseService完成查询
        List<Course> courses = courseService.allCourse();

        // 存入request域中
        request.setAttribute("courses", courses);

        request.getRequestDispatcher("adminIndex.jsp").forward(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
